home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Rice_CMS / gopher24 / gopclitm.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1993-01-24  |  7.7 KB  |  333 lines

  1. /*
  2.  *        Name: GOPCLITM REXX
  3.  *              VM TCP/IP Network GOPHER Client item processor
  4.  *      Author: Rick Troth, Rice University, Information Systems
  5.  *        Date: 1992-Dec-23
  6.  *
  7.  *       Input: one or more gopher menu lines
  8.  *      Output: zero or more information or error messages
  9.  *              (EOF does not propagate back to input)
  10.  */
  11.  
  12. /*
  13.  *      Copyright 1992 Richard M. Troth.   This software was developed
  14.  *      with resources provided by Rice University and is intended
  15.  *      to serve Rice's user community.   Rice has benefitted greatly
  16.  *      from the free distribution of software,  therefore distribution
  17.  *      of unmodified copies of this material is not restricted.
  18.  *      You may change your own copy as needed.   Neither Rice
  19.  *      University nor any of its employees or students shall be held
  20.  *      liable for damages resulting from the use of this software.
  21.  */
  22.  
  23. Trace "OFF"
  24.  
  25. Parse Upper Arg disp . '(' . ')' .
  26. If disp = "" Then disp = "OPEN"
  27. /*  Say open  */
  28.  
  29. /*  sync with input so that 'CALLPIPE COMMAND' will work  */
  30. 'PEEKTO'
  31.  
  32. 'CALLPIPE COMMAND GLOBALV SELECT GOPHER GET GOPHER PROGID'
  33.  
  34. /*  fetch fs. stem variable from GlobalVs  */
  35. 'CALLPIPE COMMAND GLOBALV SELECT GOPHER LIST | DROP' ,
  36.         '| LOCATE 1-4 / FS./ | SPEC /=/ 1 2-* NEXT | VARLOAD'
  37. If ^Datatype(fs.tube,'X') Then fs.tube = ""
  38.  
  39. /*  prepare for dynamic connection statistics  */
  40. stat = 'STEM STAT. | GOPCLIST'
  41.  
  42. Do Forever
  43.  
  44.     'PEEKTO ITEM'
  45.     If rc ^= 0 Then Leave
  46.  
  47.     'CALLPIPE COMMAND GLOBALV SELECT GOPHER PUT ITEM'
  48.  
  49.     Parse Var item name '05'x path '05'x host '05'x port '05'x xtra
  50.     Parse Var name 1 type 2 name
  51.  
  52. stat.0 = 0
  53.  
  54.     Select  /*  type  */
  55.  
  56.         When  type = '0'  Then  Call  OPENFILE
  57.  
  58.         When  type = '1'  Then  Call  OPENMENU
  59.  
  60.         When  type = '2'  Then  Call  LOOKUP
  61.  
  62.         When  type = '4'  Then  Call  OPENFILE  /* MAC */
  63.  
  64.         When  type = '5'  Then  Call  OPENFILE  /* DOS */
  65.  
  66.         When  type = '6'  Then  Call  OPENFILE  /* UUE */
  67.  
  68.         When  type = '7'  Then  Call  SEARCH
  69.  
  70.         When  type = '8'  Then  Call  TELNET
  71.  
  72.         When  type = '9'  Then  Call  BINARY
  73.  
  74.         When  type = 'T'  Then  Call  TN3270
  75.  
  76.         When  type = 'r'  | ,
  77.               type = 'v'  Then  Call  CMSBLOCK
  78.  
  79.         When  type = 'I'  | ,
  80.               type = ':'  | ,
  81.               type = 'g'  Then  Call  GRAPHICS
  82.  
  83.         Otherwise               Call  OPENFILE
  84.  
  85.         End  /*  Select  type  */
  86.  
  87. If rc ^= 0 Then 'CALLPIPE STEM STAT. | *:'
  88.  
  89.     'READTO'
  90.  
  91.     End  /*  Do  Forever  */
  92.  
  93. Exit rc * (rc ^= 12)
  94.  
  95.  
  96.  
  97. /* ------------------------------------------------------------ OPENFILE
  98.  *  View or retrieve a plain text file.
  99.  */
  100. OPENFILE:
  101.  
  102. filter = 'GOPCLITX'
  103.  
  104. If disp = "KEEP" Then Signal KEEPFILE
  105.  
  106. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,
  107.     '| GOPCLITX | GOPCLIFV | *:' ,
  108.     '! E: |' stat
  109.  
  110. Return
  111.  
  112.  
  113.  
  114. /* ------------------------------------------------------------ OPENMENU
  115.  *  View or retrieve a plain text file.
  116.  */
  117. OPENMENU:
  118.  
  119. filter = 'GOPCLITX'
  120.  
  121. If disp = "KEEP" Then Signal KEEPFILE
  122.  
  123. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,
  124.     '| GOPCLITX | GOPCLIMB | *:' ,
  125.     '! E: |' stat
  126.  
  127. Return
  128.  
  129.  
  130.  
  131. /* -------------------------------------------------------------- LOOKUP
  132.  *  Perform user lookup.   (punt to PH EXEC or equivalent)
  133.  */
  134. LOOKUP:
  135.  
  136. host = Strip(host)
  137. port = Strip(port)
  138. 'CALLPIPE COMMAND GLOBALV SELECT PHCMS PUT HOST PORT'
  139. Address "CMS" 'PH'
  140.  
  141. Return
  142.  
  143.  
  144.  
  145. /* -------------------------------------------------------------- SEARCH
  146.  */
  147. SEARCH:
  148.  
  149. 'CALLPIPE COMMAND XMITMSG 601 (APPLID GOP NOHEADER' ,
  150.         '| GOPCLIUI | VAR KEYWORDS'
  151. keywords = Strip(keywords)
  152. If keywords = "" Then Return
  153.  
  154. /*  prepend a  path<TAB>  to search string for WAIS servers  */
  155. /*  path = path || '05'x || keywords  */
  156. item = item || '05'x || keywords
  157.  
  158. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,
  159.     '| GOPCLITX | GOPCLIMB | *:'
  160.     '! E: |' stat
  161.  
  162. Return
  163.  
  164.  
  165.  
  166. /* -------------------------------------------------------------- TELNET
  167.  */
  168. TELNET:
  169.  
  170. If fs.tube ^= "" Then Do
  171.     /*  'OUTPUT' "Can't TELNET from this screen"  */
  172.     'CALLPIPE COMMAND XMITMSG 512 "TELNET"' ,
  173.             '(APPLID GOP CALLER CLI ERRMSG | *:'
  174.     Return
  175.     End /* If .. Do */
  176.  
  177. Address "COMMAND"
  178.  
  179. 'VMFCLEAR'
  180. If port = 0 Then port = ""
  181. /*  Say progid "TELNET" host port  */
  182. 'XMITMSG 30 HOST PORT (APPLID GOP CALLER CLI ERRMSG'
  183. /*  Say name  */
  184. 'XMITMSG 7 NAME (APPLID GOP CALLER CLI ERRMSG NOCOMP'
  185.  
  186. If path ^= "" Then Do
  187.     /*  Say "login with:" path  */
  188.     'XMITMSG 32 PATH (APPLID GOP CALLER CLI NOHEADER'
  189.     /*  Say "Press ENTER to continue ... "  */
  190.     'XMITMSG 33 (APPLID GOP CALLER CLI NOHEADER'
  191.     Parse External
  192.     End  /*  If  ..  Do  */
  193.  
  194. 'GLOBALV SELECT GOPHER GET TELNET'
  195. If telnet = "" Then telnet = "TELNET"
  196. Address "CMS" telnet host port
  197. 'VMFCLEAR'
  198.  
  199. Address
  200.  
  201. Return
  202.  
  203.  
  204.  
  205. /* -------------------------------------------------------------- BINARY
  206.  *  Load a "binary" (byte stream) file onto disk.
  207.  */
  208. BINARY:
  209.  
  210. filter = ""
  211.  
  212. If disp = "KEEP" Then Signal KEEPFILE
  213.  
  214. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,
  215.     '| GOPCLIFV | *:' ,
  216.     '! E: |' stat
  217.  
  218. Return
  219.  
  220.  
  221.  
  222. /* -------------------------------------------------------------- TN3270
  223.  *  This is almost exactly the same as the  TELNET  routine,
  224.  *  but we let the user run a different program,  specified in
  225.  *  global variable  TN3270,  if they wish.
  226.  */
  227. TN3270:
  228.  
  229. If fs.tube ^= "" Then Do
  230.     /*  'OUTPUT' "Can't TN3270 from this screen"  */
  231.     'CALLPIPE COMMAND XMITMSG 512 "TN3270"' ,
  232.             '(APPLID GOP CALLER CLI ERRMSG | *:'
  233.     Return
  234.     End /* If .. Do */
  235.  
  236. Address "COMMAND"
  237.  
  238. 'VMFCLEAR'
  239. If port = 0 Then port = ""
  240. /*  Say progid "TN3270" host port  */
  241. 'XMITMSG 31 HOST PORT (APPLID GOP CALLER CLI ERRMSG'
  242. /*  Say name  */
  243. 'XMITMSG 7 NAME (APPLID GOP CALLER CLI ERRMSG NOCOMP'
  244. If path ^= "" Then Do
  245.     /*  Say "login with:" path  */
  246.     'XMITMSG 32 PATH (APPLID GOP CALLER CLI NOHEADER'
  247.     /*  Say "Press ENTER to continue ... "  */
  248.     'XMITMSG 33 (APPLID GOP CALLER CLI NOHEADER'
  249.     Parse External
  250.     End  /*  If  ..  Do  */
  251.  
  252. 'GLOBALV SELECT GOPHER GET TN3270'
  253. If tn3270 = "" Then Do
  254.     'GLOBALV SELECT GOPHER GET TELNET'
  255.     If telnet = "" Then telnet = "TELNET"
  256.     tn3270 = telnet
  257.     End  /*  If  ..  Do  */
  258. Address "CMS" tn3270 host port
  259. 'VMFCLEAR'
  260.  
  261. Address
  262.  
  263. Return
  264.  
  265.  
  266.  
  267. /* ------------------------------------------------------------ CMSBLOCK
  268.  *  Save a record oriented file (type 'r' or type 'v') onto disk.
  269.  */
  270. CMSBLOCK:
  271.  
  272. filter = 'DEBLOCK CMS'
  273.  
  274. If disp = "KEEP" Then Signal KEEPFILE
  275.  
  276. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,
  277.     '| DEBLOCK CMS | GOPCLIFV | *:' ,
  278.     '! E: |' stat
  279.  
  280. Return
  281.  
  282.  
  283.  
  284. /* ------------------------------------------------------------ GRAPHICS
  285.  *  Display or save a graphics (type 'I') file.
  286.  */
  287. GRAPHICS:
  288.  
  289. filter = ""     /*  same as for  "binary"  files  */
  290.  
  291. If disp = "KEEP" Then Signal KEEPFILE
  292.  
  293. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,
  294.         '| GOPCLIGV | *: ! E: |' stat
  295.  
  296. Return
  297.  
  298.  
  299.  
  300. /* ------------------------------------------------------------ KEEPFILE
  301.  *  Save the selected file on disk.
  302.  */
  303. KEEPFILE:
  304.  
  305. If fs.tube ^= "" Then Do
  306.     'CALLPIPE COMMAND XMITMSG 508 (APPLID GOP CALLER CLI ERRMSG | *:'
  307.     Return
  308.     End  /*  If  ..  Do  */
  309.  
  310. Parse Var path 1 . 2 path    /*  discard type indicator  */
  311. file = gopclifi(path)
  312. 'CALLPIPE CMS STATE' file 'A | VAR NOTFOUND'
  313. If rc ^= 0 & rc ^= 28 Then 'CALLPIPE VAR NOTFOUND | *:'
  314. If rc = 0 Then 'CALLPIPE COMMAND XMITMSG 594 FILE' ,
  315.         '(APPLID GOP CALLER CLI ERRMSG | *:'
  316. If rc ^= 28 Then Return
  317.  
  318. If filter = "" Then
  319. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,
  320.         '| >' file 'A' ,
  321.         '! E: |' stat
  322. Else
  323. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,
  324.         '|' filter '| >' file 'A' ,
  325.         '! E: |' stat
  326.  
  327. If rc = 0 Then 'CALLPIPE COMMAND XMITMSG 571 FILE PATH' ,
  328.         '(APPLID GOP CALLER CLI ERRMSG | *:'
  329. /*  If rc = 0 Then errmsg = "Created" fn ft fm "from" path  */
  330.  
  331. Return
  332.  
  333.